"""
内容：权限管理模块中管理员列表和管理员日志公共方法
作者：陈园
"""
from ECshop.common.base import create_browser_op, create_browser, Base


# 创建一个类
class PageLogin(Base):
    # 定义属性
    url = 'http://localhost:8080/ecshop/admin/privilege.php?act=login'
    url2 = 'http://localhost:8080/ecshop/admin/index.php'
    """定义定位器"""
    close_button = ('css selector', 'span[onclick="btnCancel(this)"]')
    switch_button = ('class name', 'btn-tab')
    username = ('name', 'username')
    password = ('name', 'password')
    is_remember = ('name', 'remember')
    login_button = ('class name', 'btn-a')
    permissions = ('class name', 'icon-priv')
    admin_list = ('id', 'sub-menu-admin_list')
    add_admin = ('css selector', 'a[href="privilege.php?act=add"]')
    add_username = ('name', 'user_name')
    add_email = ('name', 'email')
    add_new_password = ('name', 'password')
    add_confirm_password = ('name', 'pwd_confirm')
    add_confirm = ('css selector', 'input[value=" 确定 "]')
    get_text = ('css selector', 'a[href="privilege.php?act=modif"]')
    get_text2 = ('css selector', 'td[style="font-size: 14px; font-weight: bold"]')
    del_name = ('css selector', 'a[href="javascript:;"]')
    click_log = ('css selector', 'a[href="admin_logs.php?act=list"]')
    down_box = ('css selector', 'select[name="ip"]')
    click_confirm = ('css selector', 'form[name="theForm"]>input')
    get_text3 = ('css selector', 'form[method="POST"]>div>table>tbody>tr>td:nth-of-type(4)')
    click_del = ('xpath', '//*[@id="listDiv"]/table/tbody/tr[2]/td[1]/span/input')
    click_del_log = ('css selector', 'input[value="清除日志"]')
    get_text_log = ('css selector', 'form[method="POST"]>div>table>tbody>tr>td:nth-of-type(5)>span')
    time_log = ('css selector', 'form[name="Form2"]>select>option:nth-child(2)')
    log_time_confirm = ('css selector', 'input[name=drop_type_date]')

    # 定义方法

    """获取网页"""

    def page_login_open_wb(self):
        self.base_open_web(self.url)

    """点击X按钮"""

    def page_login_admin_close_button(self):
        self.base_click(self.close_button)

    """切换到ecshop登录"""

    def page_login_admin_swith_button(self):
        self.base_click(self.switch_button)

    """弹窗关闭"""

    def page_login_alert(self):
        self.base_alert()

    """获取主页"""

    def page_login_open_wb2(self):
        self.base_open_web(self.url2)

    """输入用户名"""

    def page_login_input_username(self, your_content):
        self.base_input_content(self.username, your_content)

    """输入密码"""

    def page_login_input_password(self, your_content):
        self.base_input_content(self.password, your_content)

    """勾选是否保存信息"""

    def page_login_is_remember(self):
        self.base_click(self.is_remember)

    """进入iframe"""

    def page_in_iframe(self, num):
        self.base_in_frame(num)

    """退出iframe"""

    def page_quit_iframe(self):
        self.base_quit_frame()

    """立即登陆"""

    def page_login_login_button(self):
        self.base_click(self.login_button)

    """点击权限管理"""

    def page_interface_perm(self):
        self.base_click(self.permissions)

    """点击管理员列表"""

    def page_admin_list(self):
        self.base_click(self.admin_list)

    """点击添加管理员"""

    def page_add_admin(self):
        self.base_click(self.add_admin)

    """输入添加的账号"""

    def page_add_username(self, your_content):
        self.base_input_content(self.add_username, your_content)

    """输入添加的邮箱"""

    def page_add_email(self, your_content):
        self.base_input_content(self.add_email, your_content)

    """输入密码"""

    def page_add_password(self, your_content):
        self.base_input_content(self.add_new_password, your_content)

    """确认密码"""

    def page_add_confirm_password(self, your_content):
        self.base_input_content(self.add_confirm_password, your_content)

    """点击确定"""

    def page_add_confirm(self):
        self.base_click(self.add_confirm)

    """获取文本"""

    def page_new_get_text(self):
        return self.base_get_text(self.get_text)

    """点击移除"""

    def page_del_name(self):
        self.base_click(self.del_name)

    """关闭"""

    def page_login_quit(self):
        self.base_quit()

    """获取失败的文本"""

    def page_get_lows_text(self):
        return self.base_get_text(self.get_text2)

    """点击管理员日志"""

    def page_click_log(self):
        self.base_click(self.click_log)

    """按地址查看下拉框"""

    def page_drop_down_box(self, your_content):
        self.base_select(self.down_box, your_content)

    """点击查询确定"""

    def page_click_confirm(self):
        self.base_click(self.click_confirm)

    """获取IP地址文本"""

    def page_ip_text(self):
        return self.base_get_text(self.get_text3)

    """点击编号"""

    def page_click_del(self):
        self.base_click(self.click_del)

    """点击删除"""

    def page_click_del_log(self):
        self.base_click(self.click_del_log)

    """获取日志操作记录"""

    def page_get_log_text(self):
        return self.base_get_text(self.get_text_log)

    """选择日志日期"""

    def page_time_log(self):
        self.base_click(self.time_log)

    """点击日志日期确定"""

    def page_log_time_confirm(self):
        self.base_click(self.log_time_confirm)


if __name__ == '__main__':
    pass
